package com.ham.mud.classes;

import com.ham.mud.characters.Experience;
import com.ham.mud.characters.Stats;
import com.ham.mud.commands.skills.FleeSkill;
import com.ham.mud.commands.skills.KickSkill;
import com.ham.mud.commands.skills.PeekSkill;
import com.ham.mud.commands.skills.Skill;
import com.ham.mud.commands.spells.Spell;

import java.util.*;

/**
 * Created by hlucas on Jun 28, 2011 at 11:43:43 AM
 */
public class Warrior extends MudClass {
    private static List<Integer> levels = new ArrayList<Integer>();
    private static Map<Integer, List<Skill>> skills = new HashMap<Integer, List<Skill>>();
    private static Map<Integer, List<Spell>> spells = new HashMap<Integer, List<Spell>>();

    static {
        skills.put(1, Arrays.asList(new FleeSkill(), new KickSkill()));
        skills.put(3, Arrays.asList((Skill) new PeekSkill()));

        int exp = 16;
        levels.add(0);
        for(int i = 1; i < 50; i++) {
            levels.add(levels.get(i - 1) + i * exp);
        }
    }

    @Override
    public String getName() {
        return "Warrior";
    }

    @Override
    public Map<Integer, List<Skill>> getSkills() {
        return skills;
    }

    @Override
    public Map<Integer, List<Spell>> getSpells() {
        return spells;
    }

    @Override
    public Stats getBaseStats() {
        return new Stats(3, 1, 1, -3, -2, 0);
    }

    @Override
    public Integer getStartingHealth() {
        return 60;
    }

    @Override
    public Integer getHealthPerLevel() {
        return 12;
    }

    @Override
    public Integer getStartingMana() {
        return 10;
    }

    @Override
    public Integer getManaPerLevel() {
        return 2;
    }

    @Override
    public Integer getMovePerLevel() {
        return 8;
    }

    @Override
    public int getLevel(Experience experience) {
        int count = experience.getCount();
        for(int i = 0; i < levels.size(); i++) {
            Integer levelAt = levels.get(i);
            if(levelAt > count) {
                return i;
            }
        }
        return 1;
    }

    @Override
    public int getToNextLevel(Experience experience) {
        int currentLevel = getLevel(experience);
        int nextLevel = levels.get(currentLevel);
        return nextLevel - experience.getCount();
    }
}
